import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'model/data.dart';

class CheckDialog extends StatelessWidget {
  final Map<String, String> map;

  CheckDialog(this.map);

  @override
  Widget build(BuildContext context) {
    print(map);

    return Container(
      padding: const EdgeInsets.symmetric(vertical: 15, horizontal: 12),
      child: Column(
        mainAxisSize: MainAxisSize.min,
        children: [
          const Text(
            "信息核对",
            style: TextStyle(fontWeight: FontWeight.w600, fontSize: 20),
          ),
          const SizedBox(
            height: 30,
          ),
          _itemWidget("租用人姓名", map["name"] ?? ""),
          _itemWidget("租用人手机号", map["phone"] ?? ""),
          _itemWidget("开始日期", map["start"] ?? ""),
          _itemWidget("结束日期", map["end"] ?? ""),
          _itemWidget("租用天数", map["days"] ?? ""),
          const SizedBox(
            height: 20,
          ),
          InkWell(
            onTap: () {

              EasyLoading.show();
              Future.delayed(const Duration(seconds: 2), () {
                EasyLoading.showSuccess("提交成功，请等待工作人员与你联系");
                Navigator.of(context).pop(1);
              });
            },
            child: Container(
              width: 200,
              height: 50,
              alignment: Alignment.center,
              decoration: BoxDecoration(
                  borderRadius: BorderRadius.circular(10),
                  gradient: const LinearGradient(
                      colors: [Color(0xFFFF8343), Color(0xFFFF6C72)])),
              child: const Text(
                "确定租用",
                style: TextStyle(
                    color: Colors.white,
                    fontWeight: FontWeight.w600,
                    fontSize: 18),
              ),
            ),
          ),
          SizedBox(
            height: 15,
          )
        ],
      ),
    );
  }

  Widget _itemWidget(String title, String desc) {
    return Container(
      height: 50,
      padding: const EdgeInsets.symmetric(horizontal: 10),
      decoration: BoxDecoration(
          border: Border(bottom: BorderSide(color: Colors.grey.shade200))),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          Text(
            title,
            style: const TextStyle(fontWeight: FontWeight.w600),
          ),
          Text(desc)
        ],
      ),
    );
  }
}

Future showCheckDialog(BuildContext context, Map<String, String> map) {
  return showModalBottomSheet(
      context: context,
      builder: (_) => CheckDialog(map),
      isScrollControlled: true);
}
